/*
 * Alvin Baldemeca
 * TCSS 305 - Spring 2012
 * Assignment 4 Power Paint
 */

package gui.actions.paint;






import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import view.container.TetrisPaintPanel;

/**
 * This class is used to set the thickness on the PowerPaint program.
 * @author Alvin Baldemeca
 * @version 5/17/2012
 */
@SuppressWarnings("serial")
public class ThicknessAction extends AbstractAction
{
  /**
   * The value needed to convert Integer to ASCII.  
   */
  private static final int ASCII_OFFSET = 48;
  
  /**
   * The thickness of the line to be drawn on the drawing panel.
   */
  private final Integer my_thickness;
  
  /**
   * The panel to perform the action to.
   */
  private final TetrisPaintPanel my_panel;
  
  /**
   * Sets the Thickness of the shapes to be drawn on the power paint panel.
   * @param the_thickness the pixel thickness to draw the shapes
   * @param the_panel the panel that's to be drawn on.
   */
  public ThicknessAction(final Integer the_thickness, final TetrisPaintPanel the_panel)
  {
    super(the_thickness.toString());
    putValue(Action.MNEMONIC_KEY, the_thickness + ASCII_OFFSET);
    putValue(Action.SELECTED_KEY, true);
    my_thickness = the_thickness;
    my_panel = the_panel;
  }

  @Override
  public void actionPerformed(final ActionEvent the_event)
  {
    final Float thickness = my_thickness.floatValue();
    my_panel.setmyThickness(thickness);
  }

}
